In many environments where humans need to view, comprehend, and remember software parameters, variables, and other identifiers, it is generally preferable that the identifiers be mnemonic. One such environment is functional testing of computer software through its user interface. Exposing the user interface of software as a Web application is a common practice employed in software computing. As most Web applications have graphical user interfaces (GUI), functional testing of Web applications typically involves interaction with GUI components in an automated way.
Automated functional testing of Web applications using Web-based GUIs generally simulates user interaction by controlling a Web browser. A simple GUI test may include features such as (1) opening the main page of a Web application under test; (2) filling in forms or input fields, clicking buttons, etc.; and (3) asserting one or more expected outputs by examining the Web application's HTML page structure (e.g., by asserting that certain text or a component is present on the Web page after performing actions in the previous step).
In order to render Web applications accessible to automated GUI testing tools, each important visual component (input field, button, etc.) needs to have a unique and deterministic identifier (ID) assigned: (1) unique in the sense that each ID corresponds to one (and only one) component and (2) deterministic in the sense that an ID is completely determined by the state of the component (i.e., the ID value does not depend on the order of creation of individual components).
However, making a Web application accessible to automated GUI testing tools requires additional effort during its development. Oftentimes, Web application developers assign IDs to visual components manually (i.e., using statically-assigned ID values, which are either completely or partially hand-crafted). Such IDs might not be unique and deterministic across all visual components, resulting in failure (i.e. non-unique) or inexactness (i.e., non-deterministic) of relevant GUI tests.
This is due in part to an often tedious way in which each visual component in a GUI functional test requires at least one corresponding human-readable identifier to be set.
FIG. 1 shows an example of a code segment for manually assigning ID values to visual components (using regular Java code) in the related art. The code segment comprises a class definition 100 having two visual components 102. A constructor 104 of the class 100 is employed to individually call a “setId” method for each specific visual component. However, this manual method for setting identifiers may be prone to duplication when a child class is coded to override the default ID naming scheme.